<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改用户')" />
    <th:block th:include="include :: select2-css" />
</head>
<body>
<ul class="nav nav-tabs">
    <li role="presentation" class="active"><a href="#">用户基本信息</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/detail/edit/{userId}(userId=${user.userId})}">用户详情</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/coupon/{userId}(userId=${user.userId})}">我的优惠卷</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/collect/2/{userId}(userId=${user.userId})}">我收藏的零工</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/collect/0/{userId}(userId=${user.userId})}">我收藏的雇主</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/collect/1/{userId}(userId=${user.userId})}">我收藏的雇员</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/black/{userId}(userId=${userId})}">黑名单</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/flow/myflow/{userId}(userId=${user.userId})}">我的流水</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/flow/myflowpingfen/{userId}(userId=${user.userId})}">我的评分</a></li>
    <li role="presentation"><a th:href="@{/system/user/sub_user/{userId}(userId=${user.userId})}">我的下级</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/draw/}">提现列表</a></li>
    <li role="presentation"><a th:href="@{/bajiaostar/event/}">邀请管理</a></li>
    <li role="presentation"><a th:href="@{/system/user/taskCateUser/{userId}(userId=${userId})}">工种统计</a></li>
</ul>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${user}">
        <input name="userId" type="hidden" th:field="*{userId}" />
        <input name="deptId" type="hidden" th:field="*{deptId}" id="treeId" />
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户名称：</label>
                    <div class="col-sm-8">
                        <input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码：</label>
                    <div class="col-sm-8">
                        <input name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" th:field="*{phonenumber}" required>
                    </div>
                </div>
            </div>

        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" readonly="true" th:field="*{loginName}" />
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">用户状态：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="status" th:checked="${user.status == '0' ? true : false}">
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">用户性别：</label>
                    <div class="col-sm-8">
                        <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">工作技能：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" readonly="true" th:field="*{expectWorkType}" />
                    </div>
                </div>
            </div>

        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">用户头像：</label>
                    <div class="col-sm-8">
                        <select name="idavaterStatus" class="form-control m-b" th:with="type=${@dict.getType('user_imgstatus')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{idavaterStatus}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">用户标记：</label>
                    <div class="col-sm-8">
                        <select name="userMark" class="form-control m-b" th:with="type=${@dict.getType('user_mark')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{userMark}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">其他信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">备注：</label>
                    <div class="col-xs-10">
                        <textarea name="remark" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
    var prefix = ctx + "system/user";

    $("#form-user-edit").validate({
        onkeyup: false,
        rules: {
            phonenumber: {
                isPhone: true,
                remote: {
                    url: prefix + "/checkPhoneUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "userId": function () {
                            return $("#userId").val();
                        },
                        "phonenumber": function () {
                            return $.common.trim($("#phonenumber").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
        },
        messages: {
            "phonenumber": {
                remote: "手机号码已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-user-edit").serializeArray();
            var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
            data.push({"name": "status", "value": status});
            $.operate.saveTab(prefix + "/edit", data);
        }
    }

</script>
</body>
</html>